<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Eigen: Using Intel® MKL from Eigen</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>
   &#160;<span id="projectnumber">3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('TopicUsingIntelMKL.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Using Intel® MKL from Eigen </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Since Eigen version 3.1 and later, users can benefit from built-in Intel® Math Kernel Library (MKL) optimizations with an installed copy of Intel MKL 10.3 (or later).</p>
<p><a href="http://eigen.tuxfamily.org/Counter/redirect_to_mkl.php">Intel MKL </a> provides highly optimized multi-threaded mathematical routines for&#160;x86-compatible architectures. Intel MKL is available on Linux, Mac and Windows for both Intel64 and IA32 architectures.</p>
<dl class="section note"><dt>Note</dt><dd>Intel® MKL is a proprietary software and it is the responsibility of users to buy or register for community (free) Intel MKL licenses for their products. Moreover, the license of the user product has to allow linking to proprietary software that excludes any unmodified versions of the GPL.</dd></dl>
<p>Using Intel MKL through Eigen is easy:</p><ol type="1">
<li>define the <code>EIGEN_USE_MKL_ALL</code> macro before including any Eigen's header</li>
<li>link your program to MKL libraries (see the <a href="http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/">MKL linking advisor</a>)</li>
<li>on a 64bits system, you must use the LP64 interface (not the ILP64 one)</li>
</ol>
<p>When doing so, a number of Eigen's algorithms are silently substituted with calls to Intel MKL routines. These substitutions apply only for <b>Dynamic</b> <b>or</b> <b>large</b> enough objects with one of the following four standard scalar types: <code>float</code>, <code>double</code>, <code>complex&lt;float&gt;</code>, and <code>complex&lt;double&gt;</code>. Operations on other scalar types or mixing reals and complexes will continue to use the built-in algorithms.</p>
<p>In addition you can choose which parts will be substituted by defining one or multiple of the following macros:</p>
<table class="manual">
<tr>
<td><code>EIGEN_USE_BLAS</code> </td><td>Enables the use of external BLAS level 2 and 3 routines </td></tr>
<tr class="alt">
<td><code>EIGEN_USE_LAPACKE</code> </td><td>Enables the use of external Lapack routines via the <a href="http://www.netlib.org/lapack/lapacke.html">Lapacke</a> C interface to Lapack </td></tr>
<tr>
<td><code>EIGEN_USE_LAPACKE_STRICT</code> </td><td>Same as <code>EIGEN_USE_LAPACKE</code> but algorithm of lower robustness are disabled. <br  />
 This currently concerns only <a class="el" href="classEigen_1_1JacobiSVD.html" title="Two-sided Jacobi SVD decomposition of a rectangular matrix.">JacobiSVD</a> which otherwise would be replaced by <code>gesvd</code> that is less robust than Jacobi rotations. </td></tr>
<tr class="alt">
<td><code>EIGEN_USE_MKL_VML</code> </td><td>Enables the use of Intel VML (vector operations) </td></tr>
<tr>
<td><code>EIGEN_USE_MKL_ALL</code> </td><td>Defines <code>EIGEN_USE_BLAS</code>, <code>EIGEN_USE_LAPACKE</code>, and <code>EIGEN_USE_MKL_VML</code>  </td></tr>
</table>
<p>The <code>EIGEN_USE_BLAS</code> and <code>EIGEN_USE_LAPACKE*</code> macros can be combined with <code>EIGEN_USE_MKL</code> to explicitly tell <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> that the underlying BLAS/Lapack implementation is Intel MKL. The main effect is to enable MKL direct call feature (<code>MKL_DIRECT_CALL</code>). This may help to increase performance of some MKL BLAS (?GEMM, ?GEMV, ?TRSM, ?AXPY and ?DOT) and LAPACK (LU, Cholesky and QR) routines for very small matrices. MKL direct call can be disabled by defining <code>EIGEN_MKL_NO_DIRECT_CALL</code>.</p>
<p>Note that the BLAS and LAPACKE backends can be enabled for any F77 compatible BLAS and LAPACK libraries. See this <a class="el" href="TopicUsingBlasLapack.html">page </a> for the details.</p>
<p>Finally, the PARDISO sparse solver shipped with Intel MKL can be used through the <a class="el" href="classEigen_1_1PardisoLU.html">PardisoLU</a>, <a class="el" href="classEigen_1_1PardisoLLT.html">PardisoLLT</a> and <a class="el" href="classEigen_1_1PardisoLDLT.html">PardisoLDLT</a> classes of the <a class="el" href="group__PardisoSupport__Module.html">PardisoSupport module</a>.</p>
<p>The following table summarizes the list of functions covered by <code>EIGEN_USE_MKL_VML:</code> </p><table class="manual">
<tr>
<th>Code example</th><th>MKL routines </th></tr>
<tr>
<td><div class="fragment"><div class="line">v2=v1.array().sin();</div>
<div class="line">v2=v1.array().asin();</div>
<div class="line">v2=v1.array().cos();</div>
<div class="line">v2=v1.array().acos();</div>
<div class="line">v2=v1.array().tan();</div>
<div class="line">v2=v1.array().exp();</div>
<div class="line">v2=v1.array().log();</div>
<div class="line">v2=v1.array().sqrt();</div>
<div class="line">v2=v1.array().square();</div>
<div class="line">v2=v1.array().pow(1.5);</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">v?Sin</div>
<div class="line">v?Asin</div>
<div class="line">v?Cos</div>
<div class="line">v?Acos</div>
<div class="line">v?Tan</div>
<div class="line">v?Exp</div>
<div class="line">v?Ln</div>
<div class="line">v?Sqrt</div>
<div class="line">v?Sqr</div>
<div class="line">v?Powx</div>
</div><!-- fragment --> </td></tr>
</table>
<p>In the examples, v1 and v2 are dense vectors.</p>
<h1><a class="anchor" id="TopicUsingIntelMKL_Links"></a>
Links</h1>
<ul>
<li>Intel MKL can be purchased and downloaded <a href="http://eigen.tuxfamily.org/Counter/redirect_to_mkl.php">here</a>.</li>
<li>Intel MKL is also bundled with <a href="http://software.intel.com/en-us/articles/intel-composer-xe/">Intel Composer XE</a>. </li>
</ul>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Thu Apr 21 2022 13:07:55 for Eigen by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
